<?php
if(!isset($_SESSION))
{
	session_start();
}
include '../../connection/connection.php';
include "../../value/value_kr.php";
if ( !isset($_REQUEST['page'] ))
	{
    	$page = 1 ;
	}else{
		$page = $_REQUEST['page'] ;
	}
	
	$list=$_SESSION['sort'];
	$str=$_GET['str'];
	$_SESSION['sortn']=$str;
	$flagDesc=$_GET['flagDesc'];
	
	if(!isset($_REQUEST['page'])){
		$list["cf.id"]="DESC";
		$list["cf.name"]="DESC";
		$list["cf.host"]="DESC";
		$list["cf.pos_x"]="DESC";
		$list["cf.pos_y"]="DESC";
		$list["cf.go_mode"]="DESC";
		$list["cf.DVR"]="DESC";
		$list["cf.IP"];
		$list["cf.Port"]="DESC";
		$list["cf.UserID"]="DESC";
		$list["cf.PW"] = "DESC";
		$list["cf.live_time"] = "DESC";
		
		$str="cf.live_time";
		
		$_SESSION['sortn']=$str;
		$_SESSION['sort']=$list;
	}else{
		$str=$_SESSION['sortn'];
		$list=$_SESSION['sort'];
	}
$sql = "select cf.* from configcamera cf ";
$selectConfcamera = mysql_query($sql." ORDER BY ".$str." ".$list[$str], $connection);
$_SESSION['sort']=$list;
?>
<div style="overflow:scroll;overflow-x: hidden; width:100%; height:480px; background-color: #ffffff">
		     <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung"  id="tablebody2">
	     		<tbody>
					<?php 
                			$i = 0; 
			     		while ($row = mysql_fetch_array($selectConfcamera)){ 
			     			$i ++;?>
				     	<tr id="idrowconfcamera" onclick="onclickTableRow(this,<?=$row[id]?>);">
				     		<td style="text-align: center;width: 4%"><?=$i;?></td>
				     		<td style="text-align: center;width: 5%"><?=$row[id]?></td>
				     		<td style="width: 18%"><?php if ($row[name]==''){echo "&nbsp;";}else{?> <?=$row[name]?><?php }?></td>
				     		<td style="width: 6%"><?php if ($row[pos_x]==''){echo "&nbsp;";}else{?><?=$row[pos_x]?><?php }?></td>
				     		<td style="width: 6%"><?php if ($row[pos_y]==''){echo "&nbsp;";}else{?><?=$row[pos_y]?><?php }?></td>
				     		<td style="text-align: center;width: 6%"><?if ($row[go_mode]==1){echo $l_come;}else{echo $l_go;} ?></td>
				     		<td style="width: 20%"><?php if ($row[host]==''){echo "&nbsp;";}else{?><?=$row[host]?><?php }?></td>
				     		<td style="text-align: center;width: 4%"><?=$row[DVR]?></td>
				     		<td style="width: 10%"><?php if ($row[IP]==''){echo "&nbsp;";}else{?><?=$row[IP]?><?php }?></td>
				     		<td style="text-align: center;width: 6%"><?php if ($row[Port]==''){echo "&nbsp;";}else{?><?=$row[Port]?><?php }?></td>
				     		<td style="width: 9%"><?php if ($row[UserID]==''){echo "&nbsp;";}else{?><?=$row[UserID]?><?php }?></td>
				     		<td style="text-align: center;width: 6%" class="last">
				     		<?php if (strlen($row[PW])==0){echo "&nbsp;";}else{$vals="*"; for ($m=0;$m <strlen($row[PW]);$m++){?><?=$vals++;?><?php }}?></td>
				     	</tr>
			     	<?php 
			     			}
			     			if ($i>0 and $i<17) {
							 	foreach(range(0,17-$i) as $real){
							 		?>
							 		<tr>
								 		<td style="width:4%">&nbsp;</td>
								 		<td style="width:5%">&nbsp;</td>
								 		<td style="width:18%">&nbsp;</td>
									 	<td style="width:6%">&nbsp;</td>
									 	<td style="width:6%">&nbsp;</td>
									 	<td style="width: 6%;">&nbsp;</td>
									 	<td style="width:20%">&nbsp;</td>
								 		<td style="width:54%">&nbsp;</td>
								 		<td style="width:10%">&nbsp;</td>
									 	<td style="width:6%">&nbsp;</td>
									 	<td style="width:9%">&nbsp;</td>
									 	<td class="last" style="width: 6%;border-right: none !important;">&nbsp;</td>
								 	</tr>
							 	<?php }
							}?>
		     	</tbody>
		     </table>
		     </div>